/**
 * 统计页面业务中医药js
 * @author lh
 * 2016-01-15
 *
 */
//日期格式按月份显示
/**
 * 中医药数据表格属性配置
 */$('#businessTemMedicine_monthDate').val(new Date().Format('yyyy-MM'));
//根据月份和区域查询中医药信息
	function businessTemMedicineQuery(){
		$('#businessTemMedicine_Grid').datagrid({
			url:'s/medicine/table',
			method:'post',
			queryParams:{
				month:$('#businessTemMedicine_monthDate').val(),
				province:$("#btm_province").combobox('getText') == '全国' ? null: $("#btm_province").combobox('getText'),
				city:$("#btm_city").combobox('getText') == '全省' ? null: $("#btm_city").combobox('getText'),
				dist:$("#btm_district").combobox('getText') == '全市' ? null: $("#btm_district").combobox('getText')
			}
		});
	}
	$('#businessTemMedicine_Grid').datagrid({ 
		url:'s/medicine/table',
		singleSelect:true,
	    rownumbers:true,
	    columns:[[ 
  	        {field:'orgGuid',hidden:true},
  	        {field:'orgName',title:'中医馆名称',width:'10%',sortable:true,halign:'center',formatter:btm_checkDetail},
  	        {field:'outTcmd',title:'门诊中药饮片方总数',width:'11%',sortable:true,halign:'center'}, 
  	        {field:'outTcmsp',title:'门诊中成药方总数',width:'11%',sortable:true,halign:'center'},
  	        {field:'outTcmdu',title:'门诊药食两用总数',width:'11%',sortable:true,halign:'center'},
  	        {field:'outTcmpe',title:'门诊中药方总金额',width:'11%',sortable:true,halign:'center'},
  	        {field:'outTcmpePCT',title:'占比',width:'11%',sortable:true,halign:'center'}, 
  	        {field:'inTcmp',title:'住院中药方总数',width:'11%',sortable:true,halign:'center'}, 
  	        {field:'inTcmpe',title:'住院中药方总金额',width:'11%',sortable:true,halign:'center'}, 
  	        {field:'inTcmpePCT',title:'占比',width:'11%',sortable:true,halign:'center'}
  	    ]],
	    pagination:true,
	    sortable:true,
	    sortName: 'type',
	    sortOrder: 'asc'
	});
	//grid link
	function btm_checkDetail(value, row, index){
		if(value==null){
			return null;
		}else{
			return '<a href="#" onclick="tcmReloadOrCreate(\''+row.guid+'\',\''+row.orgName+'\')">'+value+'</a>';	
		}
	};
	//省级数据
	var pData=[{'id':1,'text':'全国'},{'id':2,'text':'北京市'},{'id':3,'text':'天津市'},{'id':4,'text':'河北省'}];
	$("#btm_province").combobox({
		data:pData,   
	    valueField:'id',   
	    textField:'text',
	    onLoadSuccess:function(data){
	    //	$("#btm_province").combobox('setValue',data[0].id);
	    },
	    onSelect:function(node){
	    	if(node.id==1){
	    	//	$("#btm_city + .combo").hide();
	    	//	$("#btm_district + .combo").hide();
	    	//	$("#btm_city").combobox('setValue','00');
	    	//	$("#btm_district").combobox('setValue','00');
	    	}else{
	    	//	$('#show_btm_city')[0].style.display="inline-block";
	    		btm_city();//$("#btm_city + .combo").show();
	    	}
	    }
	});
	var cData=[{'id':1,'text':'全省'},{'id':2,'text':'西市'},{'id':3,'text':'东市'},{'id':4,'text':'北市'}];
		$("#btm_city").combobox({
		//	data:cData,   
		    valueField:'id',   
		    textField:'text',
		    onLoadSuccess:function(data){
		  //  	$("#btm_city").combobox('setValue',data[0].id);
		    },
		    onSelect:function(node){
		    	if(node.id==1){
		    	//	$("#btm_district + .combo").hide();
		    		$("#btm_district").combobox('clear');
		    	}else{
		    	//	$('#show_btm_district')[0].style.display="inline-block";
		    		btm_district();//$("#btm_district + .combo").show();
		    	}
		    } 
		});
		//市级数据
		function btm_city(){
			$("#btm_city").combobox({data:cData});
		}
		var tData=[{'id':1,'text':'全市'},{'id':2,'text':'西区'},{'id':3,'text':'东区'},{'id':4,'text':'北区'}];
		$("#btm_district").combobox({
		//	data:tData,   
		    valueField:'id',   
		    textField:'text' ,
		    onLoadSuccess:function(data){
		//    	$("#btm_district").combobox('setValue',data[0].id);
		    }
		});
		//区域数据
		function btm_district(){
			$("#btm_district").combobox({data:tData});	
	}
/**	
 *  按月份查询中医药统计信息
*/
/*
	function businessTemMedicineQuery(){
		var month = $('#businessTemMedicine_monthDate').val();
		$('#businessTemMedicine_Grid').datagrid({
			url:'s/medicine/m/'+month+'/p/'+encodeURI(encodeURI("全国"))+'/c/'+encodeURI(encodeURI("全省"))+'/d/'+encodeURI(encodeURI("全市")),
			loadFilter:orange.systemPage.selfLoadFilter
		});
	}*/
